﻿using WF;
using WF.BusinessObject;
using System;
using System.Configuration;
using System.Web;
using System.Web.UI;
using WF.Common;
using WF.Model;
using System.Linq;
using System.Collections.Generic;

namespace WF.ViewModels
{
    public class ViewModelBase
    {
        protected BoFactoryBase _BusinessObjectFactory = new WebTestBoFactory();

        protected SessionManager SessionManager = new SessionManager();

        /*
        protected JobLevel CreateJobLevel()
        {
            return _BusinessObjectFactory.CreateJobLevelBO();
        }

        protected Department CreateDepartment()
        {
            return _BusinessObjectFactory.CreateDepartmentBO();
        }

        protected Job CreateJob()
        {
            return _BusinessObjectFactory.CreateJobBO();
        }

        protected JobLevelRelation CreateJobLevelRelation()
        {
            return _BusinessObjectFactory.CreateJobLevelRelationBO();
        }

        protected Position CreatePosition()
        {
            return _BusinessObjectFactory.CreatePositionBO();
        }

        protected Employee CreateEmployee()
        {
            return _BusinessObjectFactory.CreateEmployeeBO();
        }        

        

        protected DepartmentAdjustApply CreateDepartmentAdjustApply()
        {
            return _BusinessObjectFactory.CreateDepartmentAdjustApplyBO();
        }
        protected DepartmentAdjustHistory CreateDepartmentAdjustHistory()
        {
            return _BusinessObjectFactory.CreateDepartmentAdjustHistoryBO();
        }
        protected EmployeeAdjustApply CreateEmployeeAdjustApply()
        {
            return _BusinessObjectFactory.CreateEmployeeAdjustApplyBO();
        }
        protected EmployeeAdjustHistory CreateEmployeeAdjustHistory()
        {
            return _BusinessObjectFactory.CreateEmployeeAdjustHistoryBO();
        }
         
        protected WF_TopPosition CreateWF_TopPosition()
        {
            return _BusinessObjectFactory.CreateTopPositionBO();
        }

        protected DeptKindSetting CreateDeptKindSetting()
        {
            return _BusinessObjectFactory.CreateDeptKindSetting();
        }
        
        protected WF.BusinessObject.EmployeeDimissionInfo CreateEmployeeDimissionInfo()
        {
            return _BusinessObjectFactory.CreateEmployeeDimissionInfo();
        }
        */



        protected NameValuePair CreateNameValuePair()
        {
            return _BusinessObjectFactory.CreateNameValuePairBO();
        }

        protected SystemSetting CreateSystemSetting()
        {
            return _BusinessObjectFactory.CreateSystemSettingBO();
        }

        protected WF_ApplyInstance CreateWF_ApplyInstance()
        {
            return _BusinessObjectFactory.CreateWF_ApplyInstanceBO();
        }
        protected WF_ApplyInstanceDetail CreateWF_ApplyInstanceDetail()
        {
            return _BusinessObjectFactory.CreateWF_ApplyInstanceDetailBO();
        }
        protected WF_ApplyInstanceStateDetail CreateWF_ApplyInstanceStateDetail()
        {
            return _BusinessObjectFactory.CreateWF_ApplyInstanceStateDetailBO();
        }

        protected WF_AuditHistory CreateWF_AuditHistory()
        {
            return _BusinessObjectFactory.CreateWF_AuditHistoryBO();
        }

        protected WF_ApplyType CreateWF_ApplyType()
        {
            return _BusinessObjectFactory.CreateWF_ApplyType();
        }

        protected KQApply CreateKQApply()
        {
            return _BusinessObjectFactory.CreateKQApply();
        }

        //public IDataLayer DataSource
        //{
        //    set
        //    {
        //        _BusinessObjectFactory = new TestBoFactory(value);
        //    }
        //}

        #region DataBinding
        public object DataItem
        {
            get { return this; }
        }

        public int DataItemIndex
        {
            get { return 0; }
        }

        public int DisplayIndex
        {
            get { return 0; }
        }
        #endregion


        public List<RoleEntity> GetAllRole(bool includeDeleted)
        {
            Role bo = new Role();

            if (includeDeleted)
            {
                return bo.GetAll();
            }
            else
            {
                return bo.GetAll().Where(o => o.FlagDeleted == 0).ToList();
            }
        }

        public List<RoleEntity> GetAllRole()
        {
            return GetAllRole(false);

        }

        /*
        public List<JobEntity> GetAllJob(bool includeDeleted)
        {
            Job bo = new Job();

            if (includeDeleted)
            {
                return bo.GetAll();
            }
            else
            {
                return bo.GetAll().Where(o => o.FlagDeleted == 0).ToList();
            }
        }

        public List<JobEntity> GetAllJob()
        {
            return GetAllJob(false);
        } 
        */
    }
}
